import Vue from "vue";
import Router from "vue-router";


import { routeConfig } from "./router.config.js";

Vue.use(Router);

const router = new Router({
  mode: "history",
  routes: routeConfig,
});



// 配置白名单
const whiteList = ['404', 'login']

router.beforeEach((to, from, next) => {
  next();
  // const isLogin = localStorage.eleToken ? true : false;
  // if (to.path == "/login") {
  //   next();
  // } else {
  //   isLogin ? next() : next("/login");
  // }
});

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}



export default router;
